package cas;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * CA最基础的案例
 */
public class CASDemo {

    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(5);

        System.out.println(atomicInteger.compareAndSet(5,1111)+"\t"+atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(1111,1113)+"\t"+atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(1111,1119)+"\t"+atomicInteger.get());
    }
}
